
/**
 * 
 */

const { ccclass, property } = cc._decorator;

@ccclass
export default class VerificationCode extends cc.Component {

	@property(cc.SpriteAtlas)
	atlas: cc.SpriteAtlas = null;

	@property(cc.Label)
	number: cc.Label = null;

	@property(cc.Node)
	line: cc.Node = null;


	index = 0;

	onLoad() {

	}
	onEnable() {


	}
	onDisable() {

	}
	onDestroy() {

	}

	init(index) {
		this.index = index;
	}

	show() {
		this.node.active = true;
	}
	hide() {
		this.node.active = false;
	}

	fill(index, number) {
		this.show();
		var _color = "#ffffff";
		if (index == this.index) {
			_color = "#000000";
		}
		// this.line.color = new cc.Color().fromHEX(_color);

		if (index < this.index) {
			this.number.string = "";
		} else {
			this.number.string = isNaN(number) ? '' : number + '';
		}
		let spr = this.line.getComponent(cc.Sprite);
		if (typeof number == 'number' && !isNaN(number))
			spr.spriteFrame = this.atlas.getSpriteFrame('DL_srhx2');
		else
			spr.spriteFrame = this.atlas.getSpriteFrame('DL_srhx');
	}

}
